<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
if(!isset($_SESSION['adminuserid']))
{
	header("location:index.php?msg=logfirst");
	die();
}

if(isset($_REQUEST['Submit']) && ($_REQUEST['Submit'])=="Send Mail")
{
	$sqlsetting="select * from tblmystore";
	$ressetting=$obj_db->select($sqlsetting);
	if($ressetting) 
	{
		$from=$ressetting[0]['varfromemail'];
	}
	$sub = "Message From ".SITENAME." Admin";
	$to = $_REQUEST['custemail'];
	$memail = "<html><head><title>".$sub."</title></head><body>".html_entity_decode(stripslashes($_REQUEST['comments']))."</body></html>";
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$headers .= 'From: '.$from. "\r\n";
	mail($to, $sub, $memail,$headers); 
	header("location:sendmail.php?msg=emailsent");
	die();
}
?>
<?php include("inc/header.php");?>
<body>
<script type="text/javascript" src="js/tiny_mce.js"></script>
<script type="text/javascript">
	// O2k7 skin (silver)
	tinyMCE.init({
		// General options
		mode : "exact",
		elements : "comments",
		theme : "advanced",
		skin : "o2k7",
		skin_variant : "black",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		// Theme options
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_resizing : false
	});
</script>
<script language="javascript" src="js/sendmail.js"></script>
<form name="sendmail" method="post" action="">
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="middlebackground">
<tr>
<td align="center" valign="top" ><?php include(INC."top.inc.php");?></td>
</tr>
<tr>
<td valign="top">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="80%"  border="0" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td valign="top">
	<table border="0" align="center" cellpadding="0" cellspacing="0" class="border">
      <tr>
        <td height="20" colspan="3" align="center" class="bg1"><strong>Send Mail...</strong></td>
        </tr>
      <tr>
        <td align="right" colspan="3">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3" align="right">(* All fields are Required)</td>
      </tr>
      <tr>
        <td align="right" class="sltimg">*Select User</td>
        <td align="center">:</td>
        <td align="left"><select name="customer" id="customer" onChange="this.form.submit();">
              <option value="0">Select Customer</option>
              <?php 
						$sql="select * from tblcustomers";
						$resman = $obj_db->select($sql);
						if(count($resman)>0) {
							for($m=0;$m<count($resman);$m++) {
							?>
              				<option value="<?php echo stripslashes($resman[$m]['intcusid']);?>"<?php if($resman[$m]['intcusid'] == $p_cust){echo "selected";}?>>
                			<?php echo $resman[$m]['varcustemail']."</option>";					
							}
						}
					?>
              </select>
		</td>
      </tr>
      <tr>
        <td align="right" class="sltimg">&nbsp;</td>
        <td align="center">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="right" class="sltimg">*Email Address</td>
        <td align="center">:</td>
<?php
	if(isset($_REQUEST['customer']) && ($_REQUEST['customer'])!="")	{ 
		$p_cust = mysql_real_escape_string($_REQUEST['customer']);
	}
	$sql="select * from tblcustomers where intcusid='$p_cust'";
	$resman = $obj_db->select($sql);
	if(count($resman)>0)
	{
		for($m=0;$m<count($resman);$m++)
		{
		?>
        <td align="left"><input name="custemail" type="text" id="custemail" value="<?php echo stripslashes($resman[$m]['varcustemail']);?>" size="26" /></td>
		<?php
		}
	}
	
?>		
      </tr>
      <tr>
        <td align="right" class="sltimg">&nbsp;</td>
        <td align="center">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="right" valign="top" class="sltimg">*Message</td>
        <td align="center" valign="top">:</td>
        <td><textarea name="comments" rows="40" id="comments"></textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3" align="center"><input name="Submit" type="submit" class="btn" value="Send Mail" onClick="return check();"/>
          <input name="sendmail" type="hidden" id="sendmail" /></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td align="center"><?php include(INC."bottom.php");?></td>
  </tr>
</table>
</form>

</body>
</html>
